easylabel

Installation

Install from Github

devtools::install_github("myles-lewis/easylabel", auth_token="...")
library(easylabel)

Simple instructions:

To export an SVG from plotly:

Examples:

easylabel(ymatrix, x = 'x', y = 'y', col = 'col',
          scheme = c('darkgrey', 'green3', 'gold3', 'blue'),
          xlab = expression("log"[2] ~ " fold change post-Rituximab"),
          ylab = expression("log"[2] ~ " fold change post-Tocilizumab"),
          showgrid = TRUE)

Use the volcanoplot() function to quickly plot a volcano plot from DESeq2 or EdgeR objects. The useQ argument will switch to using q values for FDR.

volcanoplot(volc1, useQ = TRUE)

Use the MAplot() function to quickly plot an MA plot from DESeq2 or EdgeR objects.

MAplot(volc2, useQ = TRUE)

The fullGeneNames argument will use Bioconductor package AnnotationDbi and the org.Hs.eg.db human gene database to expand gene symbols in the Table tab. Both will need to be installed from Bioconductor.

BiocManager::install("AnnotationDbi")
BiocManager::install("org.Hs.eg.db")
volcanoplot(volc1, useQ = TRUE, fullGeneNames = TRUE)

You can add left and right sided titles using Ltitle and Rtitle to explain the direction of effect for up/downregulation. The use of expression in the example below shows how to add left/right arrow symbols to the titles. LRtitle_side = 1 puts these titles on the bottom while = 3 puts them on the top. cex.lab controls font size for these titles as well as axis titles. cex.axis controls font size for axis numbering.

The colour scheme system has been expanded to allow multiple fold change cut-offs. In this example the colours are symmetrical. xlim and ylim allow control over the range of each axis. Outlying points are shown as triangles. Outliers can be toggled off using showOutliers = FALSE.

volcanoplot(volc1,
            useQ = TRUE, fullGeneNames = TRUE,
            Ltitle=expression(symbol("\254") ~ "Non-responder"),
            Rtitle=expression("Responder" ~ symbol("\256")),
            LRtitle_side=1,
            cex.lab=0.9, cex.axis=0.8,
            fccut = c(1, 2), fdrcutoff = 0.2,
            ylim = c(0, 6), xlim=c(-5,5),
            scheme=c('darkgrey', 'blue', 'orange', 'red'))

In the next 2 plots, the colours range from blue for downregulated genes, through to red for upregulated genes. Vertical lines can be added using vline.

volcanoplot(volc1, fccut = 1, fdrcutoff = 0.2, ylim = c(0, 6), xlim=c(-5,5),
            scheme=c('darkgrey', 'blue', 'lightblue', 'orange', 'red'), vline=c(-1,1))

The next example has 6 colours and also shows how to remove the white outlines around points using outline_col = NA and use transparency instead via alpha.

library(RColorBrewer)
volcanoplot(volc1, fccut = c(1, 2), fdrcutoff = 0.2, ylim = c(0, 6), xlim=c(-5,5),
            scheme=c('darkgrey', rev(brewer.pal(9, 'RdYlBu')[-(4:6)])), alpha=0.75, outline_col=NA)

Similarly 6 colours can be applied to MA plots using 3 levels of cut-off for FDR (note the colour scheme is in a slightly different order).

MAplot(volc2, fdrcut=c(0.05, 0.01, 0.001), cex=0.8, useQ = TRUE,
       alpha=0.75, outline_col=NA,
       scheme=c('darkgrey', brewer.pal(9, 'RdYlBu')[c(7:9, 3:1)]))

The size of markers can be changed using cex (default 1). A box around the plot can be added using bty='o' (see par()). Axes can be customised by first suppressing the initial axis using xaxt='n' or yaxt='n' and then adding an axis() call using panel.last. A top title can also be added using mtext() via panel.last.

volcanoplot(volc1, useQ = TRUE, fdrcutoff = 0.2, ylim=c(0,8), xlim=c(-6,6),
            cex = 0.6,
            xaxt = 'n', yaxt = 'n', bty = 'o', panel.last = {
            axis(side = 1, at = -6:6)
            axis(side = 2, at = 0:8)
            mtext("DEG volcano plot", side = 3)
            })

Label lines can be altered using the argument labelDir or by selecting the Label direction pulldown menu in the shiny app. Options are shown below:

volcanoplot(volc1, labelDir = "radial")
volcanoplot(volc1, labelDir = "origin")

volcanoplot(volc1, labelDir = "horiz")
volcanoplot(volc1, labelDir = "vert")

volcanoplot(volc1, labelDir = "xellipse")
volcanoplot(volc1, labelDir = "yellipse")

volcanoplot(volc1, labelDir = "rect")
volcanoplot(volc1, labelDir = "oct")